package com.wj.community.mapper;

import com.wj.community.model.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author wj
 * @title: UserMapper
 * @projectName community
 * @description: TODO
 * @date 2019/8/9 17:11
 */
@Mapper
public interface UserMapper {
    /**
     * 向表中插入数据
     *
     * @param user 对象
     * @return null
     */
    @Insert("insert into user (name,account_id,token,gmt_create,gmt_modified,avatar_url) values (#{name},#{accountId},#{token},#{gmtCreate},#{gmtModified},#{avatarUrl})")
    void insert(User user);

    /**
     * 查询登录状态
     * @param token
     * @return user对象
     */
    @Select("select * from user where token=#{token}")
    User findByToken(@Param("token") String token);

    @Select("select * from user where id=#{id}")
    User findById(@Param("id") Integer id);
}
